package org.systm.menu.controller;

import org.global.basic.BasicController;
import org.springframework.web.bind.annotation.*;
import org.systm.menu.entity.Menu;
import org.systm.menu.params.ExhibitMenu;
import org.systm.menu.params.MenuServiceParams;
import org.systm.menu.service.MenuService;
import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/menu")
public class MenuController extends BasicController<String, Menu, MenuServiceParams<String>, MenuService> {
    @Resource
    MenuService menuService;

    @Override
    public MenuService service() {
        return menuService;
    }

    @Override
    public Object allAfter(List<Menu> all) throws NoSuchMethodException {
        List<ExhibitMenu> exhibitMenus = menuService.levelTree(all, ExhibitMenu.class);
        menuService.treeSort(exhibitMenus);
        return exhibitMenus;
    }
}
